package com.wcs.exam.controller.admin.req;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * Admin-试卷信息-组卷-请求参数
 * </p>
 *
 * @author wcs
 * @since 2025-03-11
 */
@Getter
@Setter
@Accessors(chain = true)
@Schema(description = "Admin-试卷信息-组卷-请求参数")
public class AdminPaperComposeReq implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @NotNull(message = "主键ID不能为空")
    @Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED)
    private Long id;

    @Valid
    @Size(min = 1, message = "试卷大题不能为空")
    @NotNull(message = "试卷大题不能为空")
    @Schema(description = "试卷大题", requiredMode = Schema.RequiredMode.REQUIRED)
    private List<PaperTitle> paperTitles;

    @Data
    @Schema(name = "AdminPaperComposeReq.PaperTitle", description = "Admin-试卷信息-组卷-试卷大题-请求参数")
    public static class PaperTitle implements Serializable {

        @Serial
        private static final long serialVersionUID = -2835564475974872607L;

        @Schema(description = "主键ID")
        private Long id;

        @Size(max = 15, message = "试卷大题名称不能超过15个字符")
        @NotNull(message = "试卷大题名称不能为空")
        @Schema(description = "标题名称(内容限制：1~15)", requiredMode = Schema.RequiredMode.REQUIRED)
        private String titleName;

        @Schema(description = "单选题数量，抽题场景使用")
        private Integer singleChoiceCount;

        @Schema(description = "多选题数量，抽题场景使用")
        private Integer multipleChoiceCount;

        @Schema(description = "判断题数量，抽题场景使用")
        private Integer judgmentCount;

        @Schema(description = "填空题数量，抽题场景使用")
        private Integer gapFillingCount;

        @Schema(description = "简答题数量，抽题场景使用")
        private Integer shortAnswerCount;

        @Valid
        @Size(min = 1, message = "试卷题目不能为空")
        @NotNull(message = "试卷题目不能为空")
        @Schema(description = "试卷试题")
        private List<PaperQuestion> paperQuestions;
    }

    @Data
    @Schema(name = "AdminPaperComposeReq.PaperQuestion", description = "Admin-试卷信息-组卷-试卷试题-请求参数")
    public static class PaperQuestion implements Serializable {

        @Serial
        private static final long serialVersionUID = -7925423782674620462L;

        @NotNull(message = "题目ID不能为空")
        @Schema(description = "题目ID", requiredMode = Schema.RequiredMode.REQUIRED)
        private Long questionId;

        @Min(value = 0, message = "试卷题目分数不能小于0")
        @Max(value = 1000, message = "试卷题目分数不能大于100")
        @Schema(description = "题目分值(取值范围：0~1000)")
        private BigDecimal questionScore;

        @Schema(description = "多选题得分方式(1:设置漏选得分、2:每个正确选项得分)")
        private Integer multiScoreWay;

        @Min(value = 0, message = "试卷题目多选题得分不能小于0")
        @Max(value = 1000, message = "试卷题目多选题得分不能大于100")
        @Schema(description = "多选题得分(取值范围：0~1000)")
        private BigDecimal multiScore;

        @Schema(description = "填空题得分方式(1:每题得分、2:每空得分)")
        private Integer fillScoreWay;

        @Min(value = 0, message = "试卷题目填空题得分不能小于0")
        @Max(value = 1000, message = "试卷题目填空题得分不能大于1000")
        @Schema(description = "填空题得分(设置填空题得分方式为2时使用，取值范围：0~1000)")
        private BigDecimal fillScore;
    }
}
